<template>

  <a-drawer
    :title="title"
    placement="right"
    :closable="true"
    :width="width"
    :visible="visible"
    @close="handleCancel"
    destroyOnClose
  >
    <gh-kind-of-work-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit"></gh-kind-of-work-form>

    <a-button type="primary" style="width: 100%" @click="handleOk">保存</a-button>

  </a-drawer>

</template>

<script>

  import GhKindOfWorkForm from './GhKindOfWorkForm'
  export default {
    name: 'GhKindOfWorkModal',
    components: {
      GhKindOfWorkForm
    },
    data () {
      return {
        title:'',
        width:'100%',
        visible: false,
        disableSubmit: false
      }
    },
    methods: {
      add () {
        this.visible=true
        this.$nextTick(()=>{
          this.$refs.realForm.add();
        })
      },
      edit (record) {
        this.visible=true
        this.$nextTick(()=>{
          this.$refs.realForm.edit(record);
        })
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        this.$refs.realForm.submitForm();
      },
      submitCallback(){
        this.$emit('ok');
        this.visible = false;
      },
      handleCancel () {
        this.close()
      }
    }
  }
</script>